import axios from 'axios';

const myaxios = axios.create({
    baseURL: 'http://localhost:1013',
    withCredentials: true
});
// 创建请求拦截器
myaxios.interceptors.request.use(
    function (config) {
        // 从本地存储获取token，这里假设token存储在localStorage中
        const token = localStorage.getItem('token');
        if (token) {
            // 如果存在token，添加到请求头中
            console.log("请求拦截器取出的TOKEN：",token)
            config.headers.Authorization = `Bearer ${token}`;
            console.log("Authorization:",config.headers.Authorization)
        }
        return config;
    }
);
// 将配置好拦截器的axios实例导出
export default myaxios;
